home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / docs / misc / MuManual.lha / MuManual / Include / mmu / context.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-07-27  |  9.5 KB  |  243 lines

  1. /*************************************************************************
  2.  ** mmu.library                                                         **
  3.  **                                                                     **
  4.  ** a system library for arbitration and control of the MC68K MMUs      **
  5.  **                                                                     **
  6.  ** © 1998 THOR-Software, Thomas Richter                                **
  7.  ** No commercial use, reassembly, modification without prior, written  **
  8.  ** permission of the authors.                                          **
  9.  ** Including this library in any commercial software REQUIRES a        **
  10.  ** written permission and the payment of a small fee.                  **
  11.  **                                                                     **
  12.  **---------------------------------------------------------------------**
  13.  ** context related definitions                                         **
  14.  **                                    **
  15.  ** $VER: 42.2 (26.07.2001)                        **
  16.  *************************************************************************/
  17.  
  18. #ifndef MMU_CONTEXT_H
  19. #define MMU_CONTEXT_H
  20.  
  21. #ifndef EXEC_TYPES_H
  22. #include <exec/types.h>
  23. #endif
  24.  
  25. /* A context keeps roughly speaking an MMU table. Lovers of unix might
  26.    want to use the name "process" instead, whereas an exec task or
  27.    a dos.library process might be called "a thread".
  28.    All tasks sharing one context share one logical addressing space. */
  29.  
  30. /* The definition of the context structure: This is something you do
  31.    not care about. */
  32.  
  33. struct MMUContext {
  34.         struct MMUContext       *ctx_succ;      /* A doubly linked list */
  35.         struct MMUContext       *ctx_pred;
  36.         /* private data here. Do not touch, modify, .... */     
  37. };
  38.  
  39.  
  40. /* A mapping node, used to define the address space. This is what you find
  41.    in the list arbitrated by GetMapping().
  42.  
  43.    This structure is stricly READ ONLY */
  44.  
  45. struct MappingNode {
  46.         struct MappingNode     *map_succ;
  47.         struct MappingNode     *map_pred;
  48.         
  49.         ULONG            map_Lower;     /* lower address this node covers. */
  50.         ULONG            map_Higher;    /* higher address, inclusive */
  51.         ULONG            map_Flags;     /* internal use only. */
  52.         ULONG            map_Properties;        /* see below for definitions */
  53.         union {
  54.                 void    *map_UserData;  /* your data if this is invalid or swapped */
  55.                 void    *map_Page;      /* destination page if bundled */
  56.                 LONG    *map_Descriptor;/* pointer to a descriptor, alternatively */
  57.                 LONG    map_Delta;      /* added to the logical address if remapped */
  58.         ULONG    map_Mask;    /* property mask for MAPP_SHARED */
  59.         }                map_un;
  60. };
  61.  
  62.  
  63.  
  64. /* Property types:
  65.    These define the "property flags" you may assign to memory with
  66.    SetProperties() and SetPageProperties(). */
  67.  
  68. #define MAPP_WRITEPROTECTED     (1<<2L)
  69. #define MAPB_WRITEPROTECTED     (2L)
  70. /* The region is write protected and the segmentation fault exception hooks 
  71.    will be called on a write access. */
  72.  
  73. #define MAPP_USED               (1<<3L)
  74. #define MAPB_USED               (3L)
  75. /* Set by the MMU on access, querried by GetPageProperties(). */
  76.  
  77. #define MAPP_MODIFIED           (1<<4L)
  78. #define MAPB_MODIFIED           (4L)
  79. /* Set by the MMU on write accesses, querried by GetPageProperties(). */
  80.  
  81. #define MAPP_CACHEINHIBIT       (1<<6L)
  82. #define MAPB_CACHEINHIBIT       (6L)
  83. /* Region is cache-inhibited, by default serialized access, precise
  84.    exception mode */
  85.  
  86. #define MAPP_SUPERVISORONLY     (1<<7L)
  87. #define MAPB_SUPERVISORONLY     (7L)
  88. /* Supervisor access only. Note that this is currently implemented by
  89.    marking the pages as invalid in the user MMU tables, not by setting
  90.    the supervisor bit. */
  91.  
  92. #define MAPP_USERPAGE0          (1<<8L)
  93. #define MAPB_USERPAGE0          (8L)
  94. /* User page attribute 0, used only by 68040, 68060.
  95.    These bits are available at special pins of the CPU,
  96.    special hardware might require this. */
  97.  
  98. #define MAPP_USERPAGE1          (1<<9L)
  99. #define MAPB_USERPAGE1          (9L)
  100. /* User page attribute 1 */
  101.  
  102. #define MAPP_GLOBAL             (1<<10L)
  103. #define MAPB_GLOBAL             (10L)
  104. /* This memory region is global. The MMU library makes currently no
  105.    effective use of this flag, and it makes only a difference for the
  106.    040 and 060 anyhow. */
  107.  
  108. #define MAPP_BLANK              (1<<11L)
  109. #define MAPB_BLANK              (11L)
  110. /* There's no memory here. If accessed, the access is quietly tolerated, 
  111.    even though nothing useful should be expected. This is mainly to work
  112.    around bad software if no enforcer is available. */
  113.  
  114. #define MAPP_SINGLEPAGE         (1<<12L)
  115. #define MAPB_SINGLEPAGE         (12L)
  116. /* Give this page a private page descriptor. This flag IS A MUST
  117.    if you want to use GetPagePropertiesA/SetPagePropertiesA on
  118.    that page.  */
  119.  
  120. #define MAPP_COPYBACK           (1<<13L)
  121. #define MAPB_COPYBACK           (13L)
  122. /* MC68040 or MC68060 advanced copyback mode enabled. The library sets this
  123.    by default for all non-chip memory. */
  124.  
  125. #define MAPP_INVALID            (1<<14L)
  126. #define MAPB_INVALID            (14L)
  127. /* The page is invalid. Accessing it results in a segmentation fault, i.e.
  128.    the library will call the appropriate exception hooks. */
  129.  
  130. #define MAPP_REMAPPED           (1<<15L)
  131. #define MAPB_REMAPPED           (15L)
  132. /* Page is redirected to a different memory region. Note that you MUST NOT
  133.    add this memory to the exec library free memory list because some DMA
  134.    devices don't support I/O from this region and the MMU library will
  135.    guru as soon as you try to place MMU tables in remapped memory. 
  136.    This might change in the future. */
  137.  
  138. #define MAPP_SWAPPED            (1<<16L)
  139. #define MAPB_SWAPPED            (16L)
  140. /* This page is currently swapped out. If a program accesses this, a 
  141.    swapped-out fault is generated. UserData is available for a swapper 
  142.    daemon, usually the memory.library. */
  143.  
  144. #define MAPP_ROM                (1<<17L)
  145. #define MAPB_ROM                (17L)
  146. /* This is read-only memory, but the library tolerates write accesses 
  147.    quietly and no hook is called on writes. Hence, this turns the memory
  148.    region effectively into a "ROM". */
  149.  
  150. #define MAPP_SHARED             (1<<18L)
  151. #define MAPB_SHARED             (18L)
  152. /* Shares the table of the parent context. Only if this context is
  153.    allocated as child context of a share-able context. */
  154.  
  155. #define MAPP_TRANSLATED         (1<<19L)
  156. #define MAPB_TRANSLATED         (19L)
  157. /* This memory region is - probably partially - under control of the 
  158.    transparent translation registers and should not be touched. 
  159.    The mmu library does not handle the transparent translation very well
  160.    and tries to get rid of them on startup. */
  161.  
  162. #define MAPP_REPAIRABLE         (1<<20L)
  163. #define MAPB_REPAIRABLE         (20L)
  164. /* This flag allows invalid or write protected pages to get repaired on
  165.    a fault by software rather than by swapping in a page. 
  166.    The mmu.library will try to make the written data available to the 
  167.    exception hook, and will try to provide readback data for the input 
  168.    pipeline of the CPU. Note that this is very useful for debugging tools 
  169.    and the like, but causes quite a lot of overhead.
  170.    Furthermore, MAPP_REPAIRABLE pages do not get user data. */
  171.  
  172. #define MAPP_IMPRECISE          (1<<21L)
  173. #define MAPB_IMPRECISE          (21L)
  174. /* If non-cacheable, allow imprecise exception mode */
  175.  
  176. #define MAPP_INDIRECT           (1<<22L)
  177. #define MAPB_INDIRECT           (22L)
  178. /* Indirect table pointer to a user-provided table. Note that the mmu library
  179.    exception handler returns always a pointer to the descriptor pointing to
  180.    your descriptor, not to your descriptor directly. */
  181.  
  182. #define MAPP_BUNDLED            (1<<23L)
  183. #define MAPB_BUNDLED            (23L)
  184. /* Several pages bundled to one physical page in memory, usually done to 
  185.    map out memory. */
  186.  
  187. #define MAPP_USER0              (1<<24L)
  188. #define MAPB_USER0              (24L)
  189. #define MAPP_USER1              (1<<25L)
  190. #define MAPB_USER1              (25L)
  191. #define MAPP_USER2              (1<<26L)
  192. #define MAPB_USER2              (26L)
  193. #define MAPP_USER3              (1<<27L)        
  194. #define MAPB_USER3              (27L)
  195. /* Strictly for you. Not touched by the library. */
  196.  
  197. #define MAPP_NONSERIALIZED      (1<<29L)
  198. #define MAPB_NONSERIALIZED      (29L)
  199. /* If non-cacheable, allow non-serialized access */
  200.  
  201. #define MAPP_IO               (1<<30L)
  202. #define MAPB_IO               (30L)
  203. /* I/O hardware. Avoid reading/writing this if you can avoid it. */
  204.  
  205.  
  206. /* error codes CreateMMUContext may generate: */
  207.  
  208. #define CCERR_TRIMMED           1    
  209. /* The MMU table has been trimmed to keep care about the enlarged 
  210.    table size. THIS IS NOT AN ERROR. */
  211.  
  212. #define CCERR_UNALIGNED             3    
  213. /* The MMU library had to perform some heavy rounding, as for
  214.    example to MAPP_REMAPPED pages. Therefore, the mapping 
  215.    might be partially wrong. You possibly do not want to use
  216.    this setup. */
  217.  
  218. #define CCERR_NO_FREE_STORE         103
  219. /* Out of memory. */
  220.  
  221. #define CCERR_INVALID_PARAMETERS    513
  222. /* Specified parameters are invalid. */
  223.  
  224. #define CCERR_UNSUPPORTED        514         
  225. /* The parameters are valid, but not supported by the 
  226.    available hardware. */
  227.  
  228. #define    CCERR_SHARENCOPY        515             
  229. /* tried to share and copy a context simulatenously, 
  230.    this cannot work. */
  231.  
  232. #define CCERR_NOTSHAREABLE        516
  233. /* the selected base context is not shareable. */
  234.  
  235. #define CCERR_SHAREOVERLEVELS        517         
  236. /* tried to make a ctx shareable that shares another context
  237.    already. Sharing does not allow building of trees. */
  238.  
  239. #define CCERR_NOPRIVSUPER        518
  240. /* sharing or shared contexts cannot have private supervisors. */
  241.  
  242. #endif
  243.